import React, { useEffect, useState } from 'react'

export default function UseEffect() {
    let [count, setCount] = useState(10)
    const changeCount = () => {
        setCount(count + 1)
    }
    useEffect(() => {
        console.log('useEffect回调函数')//任何时候都调用
    })
    useEffect(() => {
        console.log('UseEffect回调函数,[]')//当依赖值发生变化，才调用
    }, [count])
    useEffect(() => {
        return () => {
            console.log('UseEffect模拟销毁')//组件销毁时调用
        }
    }, [])

    return (
        <div>
            <h1>模拟挂载</h1>
            <div>{count}</div>
            <button onClick={changeCount}>count</button>
        </div>
    )
}

